import oled as OLED
import socket

from datetime import datetime
from datetime import timedelta


def get_host_ip():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(("8.8.8.8", 80))
        ip = s.getsockname()[0]
    finally:
        s.close()
    return ip


def __main__():
    OLED.Init()
    OLED.Clear()
    ip = get_host_ip()
    curr_time = datetime.now()
    today = curr_time.strftime("%Y-%m-%d")
    today = "DATE:" + today
    OLED.ShowString(0, 0, "One-KVM", 16, 1)
    OLED.ShowString(0, 16, ip, 16, 1)
    OLED.ShowString(0, 16 * 2, today, 16, 1)
    OLED.ShowString(0, 16 * 3, "@ye4241", 16, 1)
    OLED.Refresh()


__main__()
